#ifndef PLANE_H_
#define PLANE_H_

#include "Vec3.h"
#include "Renderable.h"

class Plane : public Renderable
{
public:
    /* Construction */
    Plane();
    Plane(const Vec3& norm, const float& distance,
          const Material& m, bool reflect,float reflectance);
    Plane(const Vec3& v1, const Vec3& v2, const Vec3& v3,
          const Material& m, bool reflect,float reflectance);
    Plane(const float& a, const float&  b, 
          const float& c, const float&  d, 
          const Material& m, bool reflect,float reflectance);

    /* Renderables virtual implementation */
    virtual bool Hit(const Ray& ray, float& tmin, ContactData& data) const;
    virtual void CalculateBox()
    {
        m_hasValidBox = true;
        m_box = BBox(-60,m_d,-60,60,m_d + 0.0001f,60);
#ifdef DEBUGGING
        m_information += "Class: Plane\n";
#endif
    }
    /* Helper functions */
    void CreateFromPoints(const Vec3& v1, const Vec3& v2, const Vec3& v3);
    void SetStats(const Vec3& normal, float distance);
    void Normalise();
    const Vec3& GetNormal() const;
    const float& GetOffset() const;

    /* Usefull distance function */
    float Distance(const Vec3& d) const;

private:
    Vec3 m_norm;
    float m_d;
};

#endif